# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
pkgname=dummyhttp
pkgver=1.0.3
pkgrel=1
pkgdesc="Super simple HTTP server that replies a fixed body with a fixed response code"
arch=('loong64' 'x86_64')
url="https://github.com/svenstaro/dummyhttp"
license=('MIT')
depends=('gcc-libs')
makedepends=('rust')
options=('!lto')
source=("$pkgname-$pkgver.tar.gz::https://github.com/svenstaro/dummyhttp/archive/v${pkgver}.tar.gz")
sha512sums=('57dfeac8f9774d647b7ce09ec6a413f5ca3140500099fda7a7819134146eba105012a629e6e050eedb2ee1ecd026e25ff55bb0acee1fe460f24c8027df6f802a')

build() {
  cd "$srcdir/$pkgname-$pkgver"

  cargo build --release --locked
}

package() {
  cd "$srcdir/$pkgname-$pkgver"

  install -Dm755 target/release/dummyhttp "$pkgdir"/usr/bin/dummyhttp

  mkdir -p "$pkgdir"/usr/share/{bash-completion/completions,zsh/site-functions,fish/vendor_completions.d}
  target/release/dummyhttp --print-completions bash > "$pkgdir"/usr/share/bash-completion/completions/dummyhttp
  target/release/dummyhttp --print-completions zsh > "$pkgdir"/usr/share/zsh/site-functions/_dummyhttp
  target/release/dummyhttp --print-completions fish > "$pkgdir"/usr/share/fish/vendor_completions.d/dummyhttp.fish

  mkdir -p "$pkgdir"/usr/share/man/man1
  target/release/dummyhttp --print-manpage | gzip > "$pkgdir"/usr/share/man/man1/$pkgname.1.gz

  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

# vim:set ts=2 sw=2 et:
